#!/usr/bin/env python
# -*- coding:utf-8 -*-


class Spring(object):
    __slots__ = ("tree", "flower")  # __slots__已经控制实例属性，但并不控制类属性

    def __getattr__(self, name):  # 过滤器
        print "You use getattr"

    def __setattr__(self, name, value):  # 过滤器
        print "You use setattr"
        self.__dict__[name] = value


"""
study __getattr__ and __setattr__
"""


class Rectangle(object):
    """
    the width and length of Rectangle
    """

    def __init__(self):
        self.width = 0
        self.length = 0

    def setSize(self, size):
        self.width, self.length = size

    def getSize(self):
        return self.width, self.length


if __name__ == "__main__":
    r = Rectangle()
    r.width = 3
    r.length = 4
    print r.getSize()
    r.setSize((30, 40))
    print r.width
    print r.length

    with open("23501.txt") as read_file, open("23503.txt", "w") as write_file:
        for line in read_file.readlines():
            write_file.write(line)

# if __name__ == '__main__':
#     print Spring.__slots__
#     print Spring.__dict__
#     t = Spring()
#     t.water = 7
#     Spring.wwater = "green"
#     print Spring.__dict__
